function transect_bathymetry(ctr,All)

%Load and plot grid data
R=region_data_all(ctr);
fname=['../../generate_profiles/data/data_',R.name,'.mat'];
load(fname,'C','P');    
subplot('position',[0.05 0.1 0.85 0.5]); hold on;

%identify transect numbers
tr=All.transect;
plt=find(tr(:,1)==ctr);
lines=unique(tr(plt,2));

offset=3*nanstd(C.T(lines(1)).z);
offset=round(offset/10)*10; 

%plot transects
for ct=1:length(lines),
    ipl1=P.T(ct).BM(1).ipl; %index of B-M location on one side
    ipl2=P.T(ct).BM(2).ipl; %index of B-M location on the other side
    
    %plot bathymetry profile
    z=-smoothPH(C.T(lines(ct)).z,11);
    dist=C.T(lines(ct)).dist;
    pl=find(isnan(z)==0 & isnan(dist)==0); 
    z=z(pl);
    dist=dist(pl);
    mz=interp1(dist,z,0,'linear','extrap');
    plot(dist,z-mz+offset*ct,'k','linewidth',1);
    plot(0,offset*ct,'ro','markersize',12,'linewidth',2); 
    
    %identify and plot the location of the B-M on each side
    bath1=-P.T(lines(ct)).iz(ipl1);
    xbm1=P.T(lines(ct)).idist(ipl1);
    bath2=-P.T(lines(ct)).iz(ipl2);
    xbm2=P.T(lines(ct)).idist(ipl2);
   
    plot(xbm1,bath1-mz+offset*ct,'r.','markersize',22);
    if ~isempty(P.T(ct).BM(2).idist)
        plot(xbm2,bath2-mz+offset*ct,'r.','markersize',22);
    end;
end;
axis tight; h4=axis;
for ct=1:length(lines);
    text(h4(2),offset*ct,num2str(lines(ct),2),'fontsize',15,'linewidth',1);
end;

%name
axis([h4(1)-diff(h4(1:2))*0.05 h4(2:4)]); h4=axis;
plot([0 0],h4(3:4),'k--','linewidth',1);
%text(h4(1),h4(4)-0.05*diff(h4(3:4)),R.name,'fontsize',18); 
text(h4(1),h4(4)-0.05*diff(h4(3:4)),'bathymetry','fontsize',18); 
axis off;

%unit bar
dx=diff(h4(1:2));
dy=diff(h4(3:4));
x=[1 1]*h4(1)+0.001*dx;
y=[h4(4)-0.15*dy h4(4)-0.15*dy-offset];
plot(x,y,'k','linewidth',1.5);
if dy>8*offset;
    label=round(linspace(0,offset,2));
end;
if dy<=8*offset & dy>4*offset;
    label=round(linspace(0,offset,3));
end;
if dy<=4*offset;
    label=round(linspace(0,offset,5));
end;

%transect number label
for ct=1:length(label);
    plot([x(1) x(1)+0.005*dx],y(2)*[1 1]+label(ct),'k','linewidth',1.5);
    text(x(1)+0.01*dx,y(2)+label(ct),[num2str(label(ct)),' m'],'linewidth',1.5,'fontsize',12);
end;

%make x-axis
subplot('position',[0.05 0.098 0.85 0.001]); 
axis([h4(1:2) 0 1]);
font(gca,15);
h=xlabel('distance (km)'); font(h,15);
